//
//  UIBarButtonItem-Ext.swift
//  DouYuSwift
//
//  Created by dingjunchuxing on 2019/7/3.
//  Copyright © 2019 text. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    
    convenience init(NormalImage: String, HightlyImage: String = "", size: CGSize = CGSize.zero) {
        
        let btn = UIButton()
        
        btn.setImage(UIImage(named: NormalImage), for: .normal)
        
        if HightlyImage != "" {
            btn.setImage(UIImage(named: HightlyImage), for: .highlighted)
        }
        
        if size == CGSize.zero{
            btn.sizeToFit()
        }else{
            btn.frame = CGRect(origin: CGPoint.zero, size: size)
        }
        
        self.init(customView :btn)
    }
}
